package com.boot.controller;

import com.entities.CommonResult;
import com.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * Description:
 *
 * @Autor: Rolin
 * datetime: 05-08-19:05
 */
@RestController
public class Controller8888 {

    private static HashMap<Integer,Object> hashMap = new HashMap<>();
    static {
        hashMap.put(1,new Payment(1L,"8e8e8e8e8e8e8e5e5e5e5e"));
        hashMap.put(2,new Payment(2L,"9a8e8e8e8e8e8e5e5e5e5e"));
        hashMap.put(3,new Payment(3L,"6d8e8e8e8e8e8e5e5e5e5e"));

    }

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/payment/nacos/{id}")
    public CommonResult<Payment> test01(@PathVariable("id")Integer id){
        Payment payment = (Payment) hashMap.get(id);
        String num =  "server.port="+serverPort+"\tid="+id;
        return new CommonResult<Payment>(num,200,payment);
    }

    //    给feign的调用测试方法
    @GetMapping("/payment/feign/{id}")
    public CommonResult<Payment> test02(@PathVariable("id")Integer id){
        Payment payment = (Payment) hashMap.get(id);
        String num =  "server.port="+serverPort+"\tid="+id;
        return new CommonResult<Payment>(num,200,payment);
    }
}
